package connection.Data;
import java.io.*;
import java.sql.Connection;
import java.sql.SQLException;

public class WeatherData {

	String weatherFile = "/media/sf_UbuntuSharedFolder/mesowest.out.20130911T2117";
	BufferedReader br = null;
	String line = "";
	StringBuilder str = new StringBuilder();
	DatabaseConnection con = new DatabaseConnection();
	
	public static void main(String[] args) throws SQLException{
		WeatherData obj= new WeatherData();
		obj.loadWeatherData();
		
	}
	
	public void loadWeatherData() throws SQLException{
		Connection conn = con.connection();
		String [] cols = null;
		try {
				br = new BufferedReader(new FileReader(weatherFile));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		try {
			while(br.readLine() != null){
					line =  br.readLine();
					while(line.isEmpty()){
						System.out.println(line);
						line =  br.readLine();
					}
						
					System.out.println(line);
					cols = line.split(" ");
					con.insertToWeather(conn,cols);
				}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
